[HVM] Fix "Many lost ticks" warning in ia32e guest
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 10 Jul 2006 14:01:49 +0000 (15:01 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Mon, 10 Jul 2006 14:01:49 +0000 (15:01 +0100)
Signed-off-by: Eddie Dong <eddie.dong@intel.com>
Signed-off-by: Xiaowei Yang <xiaowei.yang@intel.com>
xen/arch/x86/hvm/i8254.c
xen/arch/x86/hvm/intercept.c
xen/arch/x86/hvm/vmx/io.c
xen/include/asm-x86/hvm/vpit.h

index d4578156675f6a5fd390697655f1b2826b4b6073..de2d5d3b94871347b9a29da687eae7f12ac8da8e 100644 (file)
@@ -188,6 +188,12 @@ int pit_get_gate(PITState *pit, int channel)
     return s->gate;
 }
 
+void pit_time_fired(struct vcpu *v, void *priv)
+{
+    PITChannelState *s = priv;
+    s->count_load_time = hvm_get_clock(v);
+}
+
 static inline void pit_load_count(PITChannelState *s, int val)
 {
     u32   period;
@@ -209,11 +215,11 @@ static inline void pit_load_count(PITChannelState *s, int val)
     switch (s->mode) {
         case 2:
             /* create periodic time */
-            s->pt = create_periodic_time (s->vcpu, period, 0, 0);
+            s->pt = create_periodic_time (s, period, 0, 0);
             break;
         case 1:
             /* create one shot time */
-            s->pt = create_periodic_time (s->vcpu, period, 0, 1);
+            s->pt = create_periodic_time (s, period, 0, 1);
 #ifdef DEBUG_PIT
             printk("HVM_PIT: create one shot time.\n");
 #endif
index 25a715cdfd76fb7aa570da205b29229676297648..5c8e57c555ae2a683c99783cb1ec27b5106c4fef 100644 (file)
@@ -261,11 +261,12 @@ void pickup_deactive_ticks(struct periodic_time *pt)
  * period: fire frequency in ns.
  */
 struct periodic_time * create_periodic_time(
-        struct vcpu *v, 
+        PITChannelState *s,
         u32 period, 
         char irq,
         char one_shot)
 {
+    struct vcpu *v = s->vcpu;
     struct periodic_time *pt = &(v->domain->arch.hvm_domain.pl_time.periodic_tm);
     if ( pt->enabled ) {
         if ( v->vcpu_id != 0 ) {
@@ -290,6 +291,7 @@ struct periodic_time * create_periodic_time(
     pt->scheduled = NOW() + period;
     set_timer (&pt->timer,pt->scheduled);
     pt->enabled = 1;
+    pt->priv = s;
     return pt;
 }
 
index 13d3d662123772b1dd499d89ac5471ebde04479e..726782eb459715ba538f08fefa5dc87dde6dbe80 100644 (file)
@@ -75,6 +75,7 @@ interrupt_post_injection(struct vcpu * v, int vector, int type)
             pt->pending_intr_nr--;
             pt->last_plt_gtime += pt->period_cycles;
             set_guest_time(v, pt->last_plt_gtime);
+            pit_time_fired(v, pt->priv);
         }
     }
 
index e0d7698eb52f22fa1917f726649b33c3925abb76..eb3ccd12072a0f2c393d8987ab515513d18f4d60 100644 (file)
@@ -64,6 +64,7 @@ struct periodic_time {
     s_time_t scheduled;         /* scheduled timer interrupt */
     u64 last_plt_gtime;         /* platform time when last IRQ is injected */
     struct timer timer;         /* ac_timer */
+    void *priv;                 /* ponit back to platform time source */
 };
 
 typedef struct PITState {
@@ -93,9 +94,10 @@ static __inline__ s_time_t get_scheduled(
 extern void hvm_hooks_assist(struct vcpu *v);
 extern void pickup_deactive_ticks(struct periodic_time *vpit);
 extern u64 hvm_get_guest_time(struct vcpu *v);
-extern struct periodic_time *create_periodic_time(struct vcpu *v, u32 period, char irq, char one_shot);
+extern struct periodic_time *create_periodic_time(PITChannelState *v, u32 period, char irq, char one_shot);
 extern void destroy_periodic_time(struct periodic_time *pt);
 void pit_init(struct vcpu *v, unsigned long cpu_khz);
 void pt_timer_fn(void *data);
+void pit_time_fired(struct vcpu *v, void *priv);
 
 #endif /* __ASM_X86_HVM_VPIT_H__ */